package com.android.functionmanagement.globle;

import java.util.HashMap;
import java.util.Map;

import com.android.functionmanagement.util.SharedPreferencesUtils;

import android.content.Context;
import android.util.Log;
import android.util.Patterns;

public class ConstantGloble {
	//private static final String BASE_HTTP_URL = "http://test.995120.cn/HLWAppServer/uwatch.hw"; //-- 测试环境
	private static final String BASE_HTTP_URL = "http://hlw.995120.cn/HLWAppServer/uwatch.hw"; //-- 生产环境
	public static final int HTTP_PORT = 80;// http端口
	
	// 修改地址 修改此地址即可
	public static String BASE_URL = BASE_HTTP_URL;

	/** 当前日志记录级别 */
	public static final String LOG_LEVER = "verbose"; // verbose|debug|info|warn|error

	// app useragent 前缀
	public static final String APP_USER_AGENT_PREFIX = "AndroidWatch|";
	
	public static final boolean DEBUG = true;
	
	public static String getBaseUri(Context context) {
		String url = SharedPreferencesUtils.getParam(context, "url",
				BASE_HTTP_URL).toString();
		if (!Patterns.WEB_URL.matcher(url+"").matches())
			url = BASE_HTTP_URL;
		return url;
	}

	/*
	 * 通讯相关常量配置
	 */
	public static final String DEFAULT_ENCODE = "UTF-8";// 默认通讯编码方式
	public static final String HTTP = "http";// 注册通讯访问方式，以及UI工具类处理地址时使用
	public static final String HTTPS = "https";// 注册通讯访问方式，以及UI工具类处理地址时使用

	public static final String GO_METHOD_GET = "get";
	public static final String GO_METHOD_POST = "post";
	public static final String USER_AGENT = "User-Agent";
	public static final String COOKIE = "Cookie";

	public static final String CONTENT_CHARSET = "utf-8";
	public static final int CONN_PER_ROUTE_BEAN = 12;
	public static final int MAX_TOTAL_CONNECTIONS = 3; // 最大连接次数
	public static final int CONNECTION_TIME_OUT = 20 * 1000;// 设置链接超时时间 
	public static final int SOCKET_TIME_OUT = 20 * 1000;// 设置socket超时时间
	public static final int SOCKET_BUFFER_SIZE = 8 * 1024;;// 设置sokect缓存最大字节数

	public static final String HTTP_RESPOSE_CONTENT = "content";
	public static final String HTTP_RESPOSE_CODE = "resposecode";
	public static final String HTTP_OBSERVER = "observer";
	public static final String HTTP_KEY_ENGINE = "engine";
	public static final String HTTP_KEY_COMMAND = "command";
	public static final String HTTP_KEY_RESULT_DATA = "resultData";
	public static final String HTTP_KEY_CALL_BACK_METHOD = "callBackMethod";


	public static final int HTTP_CONTENT = 1;
	public static final int HTTP_CODE = 2;
	public static final int POLLING_CONTENT = 10;

	/** 本地配置文件名 */
	public static final String SHARED_PREF_FILE_NAME = "shared_pref_file";
	/** 配置文件中保存消息提示为关闭状态的消息信息 */
	public static final String OFF_SWITCHERS = "off_switchers";
	/** 客户端 COOKIES */
	public static final String CLIENT_COOKIES = "client_cookies";
	
	public static String ERROR_MESSAGE = "error_message"; // 返回状态码异常时的错误信息提示

	//无其他url的情况
	public static final String BASE_ALL_URL = BASE_URL;


	/**
	 * 日志记录级别Map
	 */
	public static final Map<String, Integer> LOG_LEVER_MAP = new HashMap<String, Integer>() {
		{
			put("verbose", Integer.valueOf(Log.VERBOSE));
			put("debug", Integer.valueOf(Log.DEBUG));
			put("info", Integer.valueOf(Log.INFO));
			put("warn", Integer.valueOf(Log.WARN));
			put("error", Integer.valueOf(Log.ERROR));
		}
	};

	public static final boolean LOG_FLAG_VERBOSE = Log.VERBOSE >= LOG_LEVER_MAP
			.get(LOG_LEVER);
	public static final boolean LOG_FLAG_DEBUG = Log.DEBUG >= LOG_LEVER_MAP
			.get(LOG_LEVER);
	public static final boolean LOG_FLAG_INFO = Log.INFO >= LOG_LEVER_MAP
			.get(LOG_LEVER);
	public static final boolean LOG_FLAG_WARN = Log.WARN >= LOG_LEVER_MAP
			.get(LOG_LEVER);
	public static final boolean LOG_FLAG_ERROR = Log.ERROR >= LOG_LEVER_MAP
			.get(LOG_LEVER);
	
	
	
	public static final String SENDDATA = "senddata";
	public static final String ALARMACTION = "alarmAction";
	public static final String EXTRATYPE = "extraType";
	
	// Add by dhy .. alarm extras {
	public static final String INTERVAL_MILLIS = "intervalMillis";
	public static final String REQUEST_CODE = "requestCode";
	public static final String ALARM_MSG = "alarm_msg";
	public static final String ALARM_SOUND_VIBRATOR = "alarm_sound_vibrator";
	
	// }..end..
	
	// 数据采集相关
	public static final String GATHER_DATA_SWITCH = "gather_period_switch";
	public static final String GATHER_DATA_PERIOD = "uploadPeriod";
	public static final boolean DEFAULT_GATHER_DATA_STATUS = true;
	public static final String DEFAULT_GATHER_DATA_PERIOD = "60";
	public static final String GATHER_DATA_ACTION = "gather_data_action";
	public static final String UNSEND_GATHER_DATA = "unsend_gather_data";
	// 计步器相关
	public static final String STEP_LAST_STEP = "last_steps";
	public static final String STEP_TODAY_TIME = "today_time";
	public static final String STEP_TODAY_STEP = "today_step";
	// 心率数据
	public static final String HEARTRATE_DATA = "heart_rate_data";
	// 数据上传类型：1-计步/2-心率/3-定位/4-sos（定位+声音文件）/5-开关机/6-低电
	public static final int UPLOAD_TYPE_OF_STEP = 1;
	public static final int UPLOAD_TYPE_OF_HR = 2;
	public static final int UPLOAD_TYPE_OF_LOCATION = 3;
	public static final int UPLOAD_TYPE_OF_SOS = 4;
	public static final int UPLOAD_TYPE_OF_POWER = 5;
	public static final int UPLOAD_TYPE_OF_LOW_BAT = 6;
	
	
	// 闹钟Action
	public static final int ALARM_ACTION_GATHER_DATA = 1;
	public static final int ALARM_REQUEST_GATHER_DATA = 1;
	//定位
	public static final int ALARM_ACTION_LOCATION_DATA = 2;
	public static final String ALARM_REQUEST_LOCATION_DATA = "alarm_request_location_data";
	//极光自定义消息
	public static final int ALARM_REQUEST_JIGUANG = 3;
	public static final String ALARM_REQUEST_JIGUANG_DATA = "alarm_request_jiguang_data";
	
	//电量
	public static final int ALARM_ACTION_BATTERY_DATA = 4;
	public static final String ALARM_REQUEST_BATTERY_DATA = "alarm_request_battery_data";
	
	//网络
	public static final int ALARM_ACTION_NETWORK_DATA = 5;
	
	//命令
	public static final int ALARM_ACTION_COMMAND_DATA = 6;
	public static final String ALARM_REQUEST_COMMAND_DATA = "alarm_request_command_data";
	
	//开机加载数据
	public static final int ALARM_ACTION_BOOTLOADTATA_DATA = 7;
	
	//获取到定位数据
	public static final int ALARM_ACTION_GETLOCATION_DATA = 8;
	
	//add by dhy .. alert alarm {

	public static final int ALARM_RING = 0x01;
	public static final int ALARM_VIBRATE = 0x10;
	
	public static final int ALARM_ACTION_ALERT_PH = 0x100;
	public static final int ALARM_ACTION_ALERT_MO = ALARM_ACTION_ALERT_PH + 0x400;
	public static final int ALARM_ACTION_END = ALARM_ACTION_ALERT_MO + 0x400;

	public static final int SOS_REQUEST_LOCATION = ALARM_ACTION_END+0x100;
	// }
	
	//reqHead start//
	/**
	 * reqHead 请求报头key
	 */
	public static final String REQHEAD = "reqHead";
	/**
	 * 终端类型 (1-ios  2-android)
	 */
	public static final String TERMINALTYPE = "terminalType";
	/**
	 * 终端编号
	 */
	public static final String TERMINALID = "terminalId";
	/**
	 * 功能号
	 */
	public static final String FUNCTIONID = "functionId";
	/**
	 * 交易日期时间 (格式：yyyyMMddhhmiss)
	 */
	public static final String TRANSTIME = "transTime";
	/**
	 * 版本号
	 */
	public static final String VERSION = "version";
	//reqHead end//
	
	
	public static final String BODY = "body";
	
	//respHead start//
	/**
	 * respHead 服务器响应 key
	 */
	public static final String RESPHEAD = "respHead";
	/**
	 * 响应代码
	 */
	public static final String RESPCODE = "respCode";
	/**
	 * 成功
	 */
	public static final String RESPCODE_SUCCESS = "0000";
	/**
	 * 响应信息
	 */
	public static final String RESPMSG = "respMsg";
	
	//respHead end//
	
	//功能列表 start
	/**
	 * 手表设备绑定
	 */
	public static final String W001 = "W001";
	/**
	 * 用户信息同步
	 */
	public static final String W002 = "W002";
	/**
	 * 手表数据上传接口
	 */
	public static final String W003 = "W003";
	/**
	 * 血压数据上传
	 */
	public static final String W004 = "W004";
	/**
	 * 心电数据上传
	 */
	public static final String W005 = "W005";
	/**
	 * 计步数据查询
	 */
	public static final String W006 = "W006";
	/**
	 * 心率数据查询
	 */
	public static final String W007 = "W007";
	/**
	 * 定位数据查询
	 */
	public static final String W008 = "W008";
	/**
	 * 极光推送
	 */
	public static final String W009 = "W009";
	//功能列表 end
	
	
	//请求参数
	/**
	 * 手表的二维码
	 */
	public static final String DEVICEID = "deviceId";
	/**
	 * 用户id
	 */
	public static final String USERID = "userId";
	/**
	 * 用户名称
	 */
	public static final String USERNAME = "userName";
	/**
	 * 服务器地址
	 */
	public static final String URL = "url";
	/**
	 * 姓名
	 */
	public static final String NAME = "name";
	/**
	 * 手机号码
	 */
	public static final String MOBILE = "mobile";
	
	//测压方案（key=archive）
	/**
	 * 收缩压上限
	 */
	public static final String SHRTOP = "shrTop";
	/**
	 * 收缩压下限
	 */
	public static final String SHRBOTTOM = "deviceId";
	/**
	 * 舒张压上限
	 */
	public static final String DIATOP = "diaTop";
	/**
	 * 舒张压下限
	 */
	public static final String DIABOTTOM = "diaBottom";
	/**
	 * 跟踪周期
	 */
	public static final String PERIODUNIT = "periodUnit";
	/**
	 * 测压开始日期
	 */
	public static final String STARTDATE = "startDate";
	/**
	 * 测压周期
	 */
	public static final String PERIOD = "period";
	/**
	 * 每周几
	 */
	public static final String DAYS = "days";
	/**
	 * 每天几点
	 */
	public static final String HOURS = "hours";
	
	
	//用药情况（key=medlist）
	/**
	 * 药物名称
	 */
	public static final String MEDNAME = "medName";
	/**
	 * 开始服用时间
	 */
//	public static final String startDate = "startDate";
	/**
	 * 每次服用剂量
	 */
	public static final String DOSAGE = "dosage";
	/**
	 * 疗程
	 */
//	public static final String period = "period";
	/**
	 * 频次
	 */
	public static final String FREQUENCY = "frequency";
	/**
	 * 饭前或饭后
	 */
	public static final String BEFOREORAFTERMEAL = "beforeOrAfterMeal";
	
	
}
